<%
# Copyright (C) 2012 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%= form_for Course.new, :html => { :id => 'new_course_form',
                                    :class => 'bootstrap-form form-horizontal',
                                    'data-turn-into-dialog' => '{"width":500,"resizable":false}',
                                    :title => t('start_a_new_course', 'Start a New Course'),
                                    :style => 'display:none;' } do |f| %>

  <div class="control-group">
    <%= f.label :name, :en => "Course Name", :class => "control-label" %>
    <div class="controls">
      <%= f.text_field :name,
                       :placeholder => t('new_course_name_placeholder', 'Course Name'),
                       :class => 'input-xlarge',
                       :maxlength => '255' %>
    </div>
  </div>
  <div id="course_code_wrapper" class="control-group" style="display:none">
    <%= f.label :course_code, :en => "Short Name", :class => "control-label" %>
    <div class="controls">
      <%= f.text_field :course_code,
                       :placeholder => t('sample_course_code', 'Course-101'),
                       :class => 'input-small',
                       :maxlength => '255' %>
      <div><%= t :course_cose_explanation, "This will be displayed in places with little space" %></div>
    </div>
  </div>

  <div class="control-group">
    <%= f.label :license,
                :en => "Content License",
                :class => "control-label" %>
    <div class="controls">
      <% cc, non_cc = Course.licenses.map { |id, attrs| [attrs[:readable_license].call, id]}.partition{|n, id| id.start_with?('cc')} %>
      <select name="course[license]" id="course_license" class="input-xlarge">
        <%= options_for_select(non_cc) %>
        <%= grouped_options_for_select([[t("Creative Commons Licenses"), cc]]) %>
      </select>
    </div>
  </div>

  <div class="control-group">
    <div class="controls">
      <label class="checkbox" for="course_is_public">
        <%= f.check_box :is_public %>
        <%= t :course_is_public_explanation, "Make course publicly visible *(student data will remain private)*", wrapper: '<div>\1</div>' %>
      </label>
    </div>
  </div>
  <input type="hidden" name="enroll_me" value="true">

  <div class="button-container">
    <button type="button"
            data-text-while-loading="<%= t 'cancel', "Cancel" %>"
            class="btn dialog_closer"><%= t 'cancel', "Cancel" %></button>
    <button class="btn btn-primary"
            data-text-while-loading="<%= t 'creating_course', 'Creating course...' %>"
            type="submit"><%= t 'create_course', 'Create course' %></button>
  </div>
<% end %>
